/*
* 如果需要使用监控统计功能，请将PUBLIC KEY 复制到DuerOS DBP平台
* 文档参考：https://dueros.baidu.com/didp/doc/dueros-bot-platform/dbp-deploy/authentication_markdown

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOELFcTwVID422pev4Pu8WoFob
oU/4cFlAJNUqbdTwfWJtrbpEWJMxV4UtOu1HRLeRTjgZwXjYeR+zqL8xbZSG/cVV
F3s6HLxwzilZW7ijsybp5YF0no5YaU6e00Isu5Yl8e5YLmM7Tbhi3A2EdwCO8WS+
+RG6ULdHP2ZypaQ3uQIDAQAB
-----END PUBLIC KEY-----

*/
import {
  Bot
} from './lib/Bot';
import privateKey from './lib/rsaKeys';

import {
  SmzdmRssPromise
} from './lib/SmzdmRssPromise';
let rssPromise = new SmzdmRssPromise();
rssPromise.fetchAll();

exports.handler = function (event, context, callback) {
  try {
    let b = new Bot(event);
    // 0: debug  1: online
    b.botMonitor.setEnvironmentInfo(privateKey, 0);
    b.run().then(function (result) {
      callback(null, result);
    }).catch(callback);
  } catch (e) {
    callback(e);
  }
}
